#书名 星级 图片链接 价格

import requests
from bs4 import BeautifulSoup

url = 'https://books.toscrape.com/'

response = requests.get(url)
print(response.status_code)
# print(response.text)

html = response.text

# bs4的使用
# 1、得到一个beautifulsoup对象
soup = BeautifulSoup(html,'html.parser')

#书名 图片链接
temp = soup.find_all(class_="image_container")
for i in temp:
    imgSrc = i.a.img['src']
    bookname = i.a.img['alt']
    print(imgSrc)
    print(bookname)

#价格
temp2 = soup.find_all(class_="product_price")
for i in temp2:
    price = i.p.string
    print(price)
#星级
temp3 = soup.find_all(class_="product_pod")
for i in temp3:
    star = i.p['class']
    print(star)